#ifndef ___L6452_H___
#define ___L6452_H___

#include "main.h"
/*******************L6452***************************/
//S0
#define L6452_S0_PORT				GPIOC
#define L6452_S0_PIN				GPIO_Pin_0
#define L6452_S0_L()				L6452_S0_PORT->BRR			=	L6452_S0_PIN
#define L6452_S0_H()				L6452_S0_PORT->BSRR			=	L6452_S0_PIN

//S1
#define L6452_S1_PORT				GPIOC
#define L6452_S1_PIN  				GPIO_Pin_1
#define L6452_S1_L()				L6452_S1_PORT->BRR 			=	L6452_S1_PIN
#define L6452_S1_H()  				L6452_S1_PORT->BSRR			=	L6452_S1_PIN

//S2
#define L6452_S2_PORT				GPIOC
#define L6452_S2_PIN  				GPIO_Pin_2
#define L6452_S2_L()  				L6452_S2_PORT->BRR 			=	L6452_S2_PIN
#define L6452_S2_H()  				L6452_S2_PORT->BSRR			=	L6452_S2_PIN

//S3
#define L6452_S3_PORT				GPIOC
#define L6452_S3_PIN  				GPIO_Pin_3
#define L6452_S3_L()  				L6452_S3_PORT->BRR 			=	L6452_S3_PIN
#define L6452_S3_H()  				L6452_S3_PORT->BSRR			=	L6452_S3_PIN

//CHSEL	Channel A 与 ChannelB选择   当chsel为低电平的时候选择A 高电平选择B
#define L6452_CHSEL_PORT			GPIOC
#define L6452_CHSEL_PIN				GPIO_Pin_4
#define L6452_CHSEL_L()     		L6452_CHSEL_PORT->BRR 		= 	L6452_CHSEL_PIN			
#define L6452_CHSEL_H()    			L6452_CHSEL_PORT->BSRR  	=	L6452_CHSEL_PIN                  

//ENCH 低电平使能被选中的channel  
#define L6452_ENCH_PORT				GPIOC
#define L6452_ENCH_PIN				GPIO_Pin_5
#define L6452_ENCH_L()     			L6452_ENCH_PORT->BRR 		= 	L6452_ENCH_PIN	
#define L6452_ENCH_H()    			L6452_ENCH_PORT->BRR 		= 	L6452_ENCH_PIN	

//SDI 数据线 串并转换
#define L6452_SDA_PORT				GPIOC
#define L6452_SDA_PIN				GPIO_Pin_6
#define L6452_SDA_L()     			L6452_SDA_PORT->BRR  		=	L6452_SDA_PIN     
#define L6452_SDA_H()    			L6452_SDA_PORT->BSRR 		=	L6452_SDA_PIN   

//SCK 时钟线 串并转换
#define L6452_SCK_PORT				GPIOC
#define L6452_SCK_PIN				GPIO_Pin_7
#define L6452_SCK_L()     			L6452_SCK_PORT->BRR  		=	L6452_SCK_PIN
#define L6452_SCK_H()    			L6452_SCK_PORT->BSRR 		=	L6452_SCK_PIN

//LATCHCLEAR 高电平会复位锁存器 就是让锁存器的引脚全部输出低电平
#define L6452_LATCHCLEAR_PORT		GPIOC
#define L6452_LATCHCLEAR_PIN		GPIO_Pin_8
#define L6452_LATCHCLEAR_L()     	L6452_LATCHCLEAR_PORT->BRR	= 	L6452_LATCHCLEAR_PIN
#define L6452_LATCHCLEAR_H()    	L6452_LATCHCLEAR_PORT->BSRR = 	L6452_LATCHCLEAR_PIN

//latchdata 上升沿 触发锁存器锁存数据
#define L6452_LATCHDATA_PORT		GPIOC
#define L6452_LATCHDATA_PIN			GPIO_Pin_9
#define L6452_LATCHDATA_L()     	L6452_LATCHDATA_PORT->BRR  	= 	L6452_LATCHDATA_PIN
#define L6452_LATCHDATA_H()         L6452_LATCHDATA_PORT->BSRR 	= 	L6452_LATCHDATA_PIN

//NCEN 可以控制使用墨盒检测功能还是打印功能 如果高电平则使用墨盒检测功能  低电平则使用的是喷墨检测功能
#define L6452_NCEN_PORT				GPIOC
#define L6452_NCEN_PIN        		GPIO_Pin_10
#define L6452_NCEN_L()        		L6452_NCEN_PORT->BRR  		= 	L6452_NCEN_PIN
#define L6452_NCEN_H()        		L6452_NCEN_PORT->BSRR 		= 	L6452_NCEN_PIN

//NCOUT	墨盒检测功能中使用的 如果NCOUT是高电平则说明喷头是好的， 否则为坏的
#define L6452_NCOUT_PORT			GPIOA
#define L6452_NCOUT_PIN        		GPIO_Pin_6
#define L6452_NCOUT_L()        		L6452_NCOUT_PORT->BRR  		= 	L6452_NCOUT_PIN
#define L6452_NCOUT_H()        		L6452_NCOUT_PORT->BSRR 		= 	L6452_NCOUT_PIN

//longpulse 低电平 使能 STAGES 也就是power开始输出 并且复位锁存器
#define L6452_LONGPULSE_PORT		GPIOC
#define L6452_LONGPULSE_PIN  		GPIO_Pin_11
#define L6452_LONGPULSE_L() 		L6452_LONGPULSE_PORT->BRR	=	L6452_LONGPULSE_PIN     
#define L6452_LONGPULSE_H()  		L6452_LONGPULSE_PORT->BSRR	=	L6452_LONGPULSE_PIN    

//shortpulse 低电平 使能 STAGES 也就是power开始输出 并且复位锁存器
#define L6452_SHORTPULSE_PORT  		GPIOC
#define L6452_SHORTPULSE_PIN   		GPIO_Pin_12
#define L6452_SHORTPULSE_L()   		L6452_SHORTPULSE_PORT->BRR	=	L6452_SHORTPULSE_PIN
#define L6452_SHORTPULSE_H()   		L6452_SHORTPULSE_PORT->BSRR	=	L6452_SHORTPULSE_PIN

//RESET 如果为低电平则会失能所有功能 并且清所有的寄存器
#define L6452_RESET_PORT			GPIOC
#define L6452_RESET_PIN				GPIO_Pin_13
#define L6452_RESET_L()     		L6452_RESET_PORT->BRR		=	L6452_RESET_PIN
#define L6452_RESET_H()    			L6452_RESET_PORT->BSRR		=	L6452_RESET_PIN


/*--------------------------------------------------------*/
//244EN
#define EN_244_PORT					GPIOC
#define EN_244_PIN  				GPIO_Pin_15
#define EN_244_ON()     			EN_244_PORT->BRR  			=	EN_244_PIN 
#define EN_244_OFF()    			EN_244_PORT->BSRR 			=	EN_244_PIN

//墨盒喷墨时间
#define INK_JET_TIME	            DRAWING_INK_JET_TIME 
//墨盒加热保持时间
#define HEAT_INK_HOLD_TIME	    	DRAWING_HEAT_INK_HOLD_TIME					
//通道宏定义
#define CHANNEL_A 					1
#define CHANNEL_B 					2


//声明函数
extern void L6452_Init(void);
extern void L6452_ChannelOutput(uint8_t channel,uint8_t numb);
extern void L6452_PowerOutput(uint16_t Pn);
extern void L6452_HeatInk(uint32_t cycle);
extern void L6452_ModifHeatProperty(uint16_t longcnt,uint16_t shortcnt) ;
extern uint16_t L6452_GetLongHeatCnt(void);
extern uint16_t L6452_GetShortHeatCnt(void);

#endif
